package com.hlhj.carview.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.hlhj.carview.Iview.AddCarView
import com.hlhj.carview.bean.MyBaseBean
import com.hlhj.carview.http.Apis
import com.hlhj.carview.http.CustomAction
import com.hlhj.carview.http.LoadingAction
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response

/**
 * Created by Never Fear   on 2018\12\21 0021.
Never More....
 */
class AddCarModule :BaseModule {
    var listener:AddCarView?=null

    fun addCar(car_number:String,number_type:String,car_type:String,car_appearance:String,img:String,c:Context){
        Apis?.
                addCar(car_number, number_type, car_type, car_appearance, img)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MyBaseBean>>(c){
                                override fun httpSuccess(t: Response<MyBaseBean>) {
                                    listener?.setAddCarResult(t.body())
                                }
                            })
                }
    }

}